const fs = require('fs');
const path = require('path');

const ymlPath = path.join(__dirname, 'electron-builder', 'latest.yml');
const notes = fs.readFileSync(path.join(__dirname, 'release-notes.txt'), 'utf-8');

let yml = fs.readFileSync(ymlPath, 'utf-8');
if (!/releaseNotes:/i.test(yml)) {
  yml += `\nreleaseNotes: |\n  ${notes.replace(/\n/g, '\n  ')}\n`;
  fs.writeFileSync(ymlPath, yml, 'utf-8');
}